package com.kgc.ubatnet.ubatnetuserservice.service;

import com.kgc.ubatnet.bean.*;
import com.kgc.ubatnet.service.CatalogService;
import com.kgc.ubatnet.ubatnetuserservice.mapper.PmsBaseCatalog1Mapper;
import com.kgc.ubatnet.ubatnetuserservice.mapper.PmsBaseCatalog2Mapper;
import com.kgc.ubatnet.ubatnetuserservice.mapper.PmsBaseCatalog3Mapper;
import org.apache.dubbo.config.annotation.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CatalogServiceImpl implements CatalogService{
    @Resource
    PmsBaseCatalog1Mapper pmsBaseCatalog1Mapper;
    @Resource
    PmsBaseCatalog2Mapper pmsBaseCatalog2Mapper;
    @Resource
    PmsBaseCatalog3Mapper pmsBaseCatalog3Mapper;
    @Override
    public List<PmsBaseCatalog1> getCatalog1() {
        return pmsBaseCatalog1Mapper.selectByExample(null);
    }

    @Override
    public List<PmsBaseCatalog2> getCatalog2(Long catalog1) {
        PmsBaseCatalog2Example example=new PmsBaseCatalog2Example();
        PmsBaseCatalog2Example.Criteria criteria = example.createCriteria();
        criteria.andCatalog1IdEqualTo(catalog1);
        return pmsBaseCatalog2Mapper.selectByExample(example);
    }

    @Override
    public List<PmsBaseCatalog3> getCatalog3(Long catalog2) {
        PmsBaseCatalog3Example example=new PmsBaseCatalog3Example();
        PmsBaseCatalog3Example.Criteria criteria = example.createCriteria();
        criteria.andCatalog2IdEqualTo(catalog2);
        return pmsBaseCatalog3Mapper.selectByExample(example);
    }
}
